import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {longLimtVal, longLimtValAndNotBlank, rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {UploadTypeEnum} from "@/components/Form/src/jeecg/components/JUpload";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '证件类型',
    align:"center",
    dataIndex: 'paperType_dictText'
   },
   {
    title: '证件号码',
    align:"center",
    dataIndex: 'paperNumber'
   },
   {
    title: '手机号码',
    align:"center",
    dataIndex: 'phone'
   },
   {
    title: '头像',
    align:"center",
    dataIndex: 'photo',
     slots: { customRender: 'img' },
   },
  {
    title: '授权开始时间',
    align:"center",
    dataIndex: 'inStartTime',
  },
  {
    title: '授权结束时间',
    align:"center",
    dataIndex: 'inEndTime',
  },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '权限类型',
    align:"center",
    dataIndex: 'type_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "姓名",
      field: 'name',
      component: 'JInput',
      //colProps: {span: 6},
 	},
  {
    label: '证件类型',
    field: 'paperType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"paperType",
      stringToNumber:true,
    },
  },


	{
      label: "证件号码",
      field: 'paperNumber',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "权限类型",
      field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"visit_bw_type"
    }
      //colProps: {span: 6},
 	},
  {
    label: "",
    field: 'queryFrom',
    component: 'InputNumber',
    show:false
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        {
          required:true,
          validator: (_, value) => {
            return longLimtValAndNotBlank(value,10)
          },
        },
      ];
    },
  },
  {
    label: '证件类型',
    field: 'paperType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"paperType",
      stringToNumber:true,
    },
  },
  {
    label: '证件号码',
    field: 'paperNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        {
          required:true,
          validator: (_, value) => {
            return longLimtVal(value,20)
          },
        },
      ];
    },
  },
  {
    label: '手机号码',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        {
          validator: (_, value) => {
            return longLimtVal(value,20)
          },
        },
      ];
    },
  },
  {
    label: '头像',
    field: 'photo',
    component: 'JUpload',
    helpMessage: '最多上传1张图片',
    componentProps: {
      fileType: UploadTypeEnum.image,
      bizPath: 'bwphoto',
      maxCount: 1,
    },
  },
  {
    label: '授权开始时间',
    field: 'inStartTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '授权结束时间',
    field: 'inEndTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
        {
          validator: (_, value) => {
            return longLimtVal(value,50)
          },
        },
      ];
    },
  },
  {
    label: '权限类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"visit_bw_type",
      stringToNumber:true,
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '姓名',order: 0,view: 'text', type: 'string',},
  paperType: {title: '证件类型',order: 1,view: 'number', type: 'number',},
  paperNumber: {title: '证件号码',order: 2,view: 'text', type: 'string',},
  phone: {title: '手机号码',order: 3,view: 'text', type: 'string',},
  photo: {title: '头像',order: 4,view: 'text', type: 'string',},
  remark: {title: '备注',order: 5,view: 'text', type: 'string',},
  type: {title: '黑白类型',order: 6,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
